home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20031118-20041115 / 000063_fdc@columbia.edu_Mon Dec 15 17:04:30 2003.msg < prev    next >
Lisp/Scheme  |  2020-01-01  |  4KB  |  86 lines

  1. Path: newsmaster.cc.columbia.edu!not-for-mail
  2. From: Frank da Cruz <fdc@columbia.edu>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: EMACS Kermit Mode
  5. Date: 15 Dec 2003 21:57:46 GMT
  6. Organization: Columbia University
  7. Lines: 69
  8. Message-ID: <slrnbtsbiq.p1c.fdc@sesame.cc.columbia.edu>
  9. Reply-To: fdc@columbia.edu
  10. NNTP-Posting-Host: sesame.cc.columbia.edu
  11. X-Trace: newsmaster.cc.columbia.edu 1071525466 26375 128.59.59.56 (15 Dec 2003 21:57:46 GMT)
  12. X-Complaints-To: postmaster@columbia.edu
  13. NNTP-Posting-Date: 15 Dec 2003 21:57:46 GMT
  14. User-Agent: slrn/0.9.7.4 (SunOS)
  15. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:14743
  16.  
  17. On the recent Slashdot thread, the point was made (several times) that
  18. people who like Kermit tend to be the same people who like EMACS.  This
  19. was either a compliment or an insult, depending on the speaker, but
  20. there's definitely some truth to it my case!
  21.  
  22. Many of us write and edit Kermit scripts in EMACS.  But wouldn't it be
  23. so much better if EMACS had a Kermit Mode that automatically indented
  24. appropriately, lined up comments, etc?  Now you can have one.  The
  25. following instructions should work with all versions of GNU EMACS back
  26. to 19.34.  Thanks to Alan Mackenzie (Munich, Germany) for lots of help
  27. with this:
  28.  
  29.  1. Get the latest cc-mode (5.30.8 or later) from:
  30.  
  31.       http://cc-mode.sourceforge.net/release.php
  32.  
  33.  2. Install it for real on your computer or, if you can't do that,
  34.     install it in your own file space.  Installation is explained in
  35.     the README file that comes in the package.
  36.  
  37.  3. If you installed the new cc-mode in your own area, you have to tell
  38.     EMACS where to find it.  Add the following to your ~/.emacs file:
  39.  
  40.       (setq load-path (cons "~myuserid/cc-mode-5.31" load-path))
  41.  
  42.     (replacing "~myuserid/cc-mode-5.31" with the path of the directory
  43.     where you installed the new cc-mode).
  44.  
  45. Now creating a minimal but serviceable Kermit Mode is easy; just add the
  46. following to your ~/.emacs file:
  47.  
  48.     ; Kermit mode
  49.  
  50.     (autoload 'awk-mode "cc-mode" nil t) ; Must load new Awk mode!
  51.  
  52.     (define-derived-mode kermit-mode
  53.       awk-mode "Kermit"
  54.       "Major Mode for Kermit Scripts"
  55.       (auto-fill-mode 1)
  56.       (setq fill-column 78)
  57.       (setq indent-tabs-mode nil)
  58.       (setq brace-else-brace 1)
  59.       (setq comment-multi-line nil)
  60.       (setq comment-column 40)
  61.       (setq comment-start "\# ")
  62.       (setq comment-end ""))
  63.  
  64. Brief explanation: recent releases of EMACS allow you define new major
  65. modes that are derived from existing ones.  Awk is a language that is
  66. somewhat similar to Kermit: it uses braces like C, but does not terminate
  67. or separate statements with any particular character (like C does with
  68. semicolon).  Instead (in the general case) each statement is on its own
  69. line.  We use "#" as the comment character in kermit-mode because using
  70. semicolon confuses the underlying EMACS libraries too much.  The old Awk
  71. mode didn't work well enough to base Kermit mode on, the new does.
  72.  
  73. You might also want to associate Kermit Mode with .ksc files.  In that
  74. case add .ksc to your auto-mode-list:
  75.  
  76.       (setq auto-mode-alist (append '(("\\.ksc" . kermit-mode))))
  77.  
  78. This causes EMACS to switch to Kermit Mode automatically whenever you
  79. visit a file whose name ends in ".ksc".
  80.  
  81. Kermit Mode not perfect, but it's close.  The main problem I've noticed so
  82. far is that SWITCH case labels are not "outdented".  Anybody who knows
  83. EMACS LISP better than I do is welcome to make improvements!
  84.  
  85. - Frank
  86.